package com.sw.paisong.util;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

import com.sw.paisong.vo.SessionVO;

public class SessionUtil {

	public static final void setCurrentSession(SessionVO sessionVO) {

		Subject subject = SecurityUtils.getSubject();

		if (null != subject) {
			Session session = subject.getSession();
			if (null != session) {
				session.setAttribute(Constants.CURRENT_SESSION, sessionVO);
			}
		}
	}

	public static final SessionVO getCurrentSession() {
		Subject subject = SecurityUtils.getSubject();

		if (null != subject) {
			Session session = subject.getSession();
			if (null != session) {
				SessionVO sessionVO = (SessionVO) session.getAttribute(Constants.CURRENT_SESSION);
				if (null != sessionVO) {
					return sessionVO;
				}
			}
		}
		return null;
	}

}
